﻿<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'userList.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<script type="text/javascript">
		function delUser(resid){
			if(confirm("您确定删除吗？")){
				$.ajax({ 
				    type: "POST",
					url: "${ctx}/pages/user/delete.action",
					data:{'id':resid},
					dataType:"json",
					success: function(data){
	     		 		if(data==1){
	     		 			window.location.reload(); 
	     		 		}else{
	     		 			alert("删除失败！");
	     		 		}
	     		 	}
	     		 });
			}			
		}
		
		function bethDelUsers(){
			var ids = "";
				$("input[name='cbox']").each(function(){
					if($(this).is(":checked")){
						ids = ids + $(this).val()+",";
					}					
				});
				if(ids==""){
				  alert("请选择要删除的模块");
				  return ;
				}
			if(confirm("您确定删除吗？")){
				$.ajax({ 
				    type: "POST",
					url: "${ctx}/pages/user/delete.action",
					data:{'ids':ids},
					dataType:"json",
					success: function(data){
	     		 		if(data==1){
	     		 			window.location.reload(); 
	     		 		}
	     		 	}
	     		 });
			}			
		}
		
		function goPage(pageNO){
			
		 	var url = "${ctx}/pages/user/list.action?pageNO="+pageNO;
		 	document.location.href =url;
		}
	
	</script>
  </head>
  
  <body>
  <div id="body-wrapper">
   	<div id="main-content">
	<div class="content-box">
      <!-- Start Content Box -->
      <div class="content-box-header">
        <h3 style="cursor: s-resize;">用户列表</h3>
        <div class="clear"></div>
      </div>
      <!-- End .content-box-header -->
      <div style="display: block;" class="content-box-content">
        <div style="display: block;" id="tab1" class="tab-content default-tab">
          <table>
            <thead>
            <tr>
                <td colSpan="6">
                  <myButton:bottonTag name="创建用户" preUrl="/pages/user/add.action" href="${ctx}/pages/user/add.action" />
                  <div class="clear"></div>
                </td>
              </tr>
              <tr>
                <th>
                  <input class="check-all" type="checkbox">
                </th>
                <th>用户名</th>
                <th>真实姓名</th>
                <th>手机号</th>
                <th>登录次数</th>
                <th>创建时间</th>
                <th>状态</th>
                <th>操作</th>
              </tr>
            </thead>
            <tfoot>
              <tr>
                <td colSpan="7">
                  <div class="pagination"> 
                  	<c:if test="${page.curPage>1}">
                  	<a title="Next Page" href="javascript:void(0);" onclick="goPage('${page.curPage-1}');">«  上一页</a>
                  	</c:if>
                  	<c:if test="${page.curPage<page.totalPage}">
                  		<a title="Next Page" href="javascript:void(0);" onclick="goPage('${page.curPage+1}');">下一页 »</a>
                  	</c:if>
                  </div>
                  <div class="clear"></div>
                </td>
              </tr>
            </tfoot>
            <tbody>
              <c:forEach items="${userList}" var="user" varStatus="i">
              	 <tr  <c:if test="${i.count%2!=0}">class="alt-row"</c:if> >
               	 <td>
                  <input type="checkbox" value="${user.id}">
                </td>
                <td>${user.userName }</td>
                <td>${user.realName }</td>
                <td>${user.phone }</td>
                <td>${user.userCount}</td>
                <td><fmt:formatDate value="${user.createDate}"  pattern="yyyy-MM-dd"/></td>
                <td><c:choose>
                 	<c:when test="${user.status=='1'}">
                 		启用
                 	</c:when>
                 	<c:otherwise>
                 		锁定
                 	</c:otherwise>
                 </c:choose>
                </td>
                <td>
                  <!-- Icons -->
                 <myButton:bottonTag name="修改" preUrl="/pages/user/edit.action" href="${ctx}/pages/user/edit.action?id=${user.id}" />&nbsp;&nbsp;<myButton:bottonTag name="删除" preUrl="/pages/user/delete.action" href="javascript:void(0)" onclick="delUser('${user.id }');" />
              </tr>
              </c:forEach>
            </tbody>
          </table>
        </div>
      </div>
      <!-- End .content-box-content -->
    </div>
</div>
</div>
  </body>
</html>
